/*
 * WeatherPopup.h
 *
 *  Created on: Nov 18, 2010
 *      Author: quan
 */

#ifndef WEATHERPOPUP_H_
#define WEATHERPOPUP_H_
#include <FUi.h>
#include <FBase.h>
#include <FGraphics.h>
#include <FMedia.h>
#include <FBaseDataType.h>
#include <FNet.h>
#include <FLocations.h>
#include "PopupUtil.h"
//class sendSMSClass;
//class XmlClass;
class WeatherPopup:
		public Osp::Base::String,
		public Osp::Ui::IActionEventListener,
		public Osp::Media::IImageDecodeUrlEventListener,
		public Osp::Net::Http::IHttpTransactionEventListener
{
public:
	WeatherPopup();
	virtual ~WeatherPopup();
	void Construct();
	void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
	void ShowPopup(int mode,String address, String cond, String temp, String humi, String wind, String Pres, String url);
	void HidePopup(void);
	result GetImage(Osp::Base::String);
	void  OnImageDecodeUrlReceived (RequestId reqId, Osp::Graphics::Bitmap *pBitmap, result r, const Osp::Base::String errorCode, const Osp::Base::String errorMessage);

	//for get weather info
	void OnTransactionReadyToRead(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen);
	void OnTransactionAborted(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, result r);
	void OnTransactionReadyToWrite(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, int recommendedChunkSize);
	void OnTransactionHeaderCompleted(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, int headerLen, bool rs);
	void OnTransactionCompleted(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction);
	void OnTransactionCertVerificationRequiredN(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, Osp::Base::String* pCert);
	void getWeatherByLatLon(String yLat,String yLon);
	void getWeathersByCityCode(String citycode);
//	void WeatherWarning(float temp, String Cond);
	void displayWeather(Osp::Locations::Controls::Map*__pMap,double yLat, double yLon);
	void getCityCode(String CityName);

private:
	Osp::Ui::Controls:: Popup*   __popUp;
	Osp::Ui::Controls::Button* __button1,*__button2;
	Osp::Ui::Controls::Label* __label1,*__label2,*__label4,*__label5,*__label6,*__label7;
	static const int ID_POPUP_BYE = 11101;
	RequestId reqId;
	Osp::Graphics::Bitmap* bitmap;
	Osp::Media::Image image1;
	Osp::Base::Utility::Uri srcImageUrl;

	//for get weather info
	Osp::Net::Http::HttpSession*	__pSession;
	Osp::Net::Http::HttpSession* __pSession2;
	Osp::Base::String* __temp;
	Osp::Base::String* __humid;
	Osp::Base::String* __speed;
	Osp::Base::String* __pressure;
//	sendSMSClass* psendSMSClass;//quan add 11/11
//	XmlClass* pXmlClass;
	Osp::Base::String* __cond;
	Osp::Base::String Address;
	Osp::Base::String* __url;
//	int WeatherID ;
//	String smsInfo;
//	String infoWeather;
	PopupUtil* popUpUtil;

	int start;
};

#endif /* WEATHERPOPUP_H_ */
